package cn.jackyu.stock.stock_grid_trading.event.consumer;

import org.springframework.stereotype.Component;

/**
 * @author yuyong
 * @date 2025-03-13
 */
@Component
public abstract class AbstractStockDataConsumer implements StockDataConsumer {

    private final StockDataConsumerManager stockDataConsumerManager;

    public AbstractStockDataConsumer(StockDataConsumerManager stockDataConsumerManager) {
        this.stockDataConsumerManager = stockDataConsumerManager;
    }

    /**
     * 获取股票代码
     */
    public abstract String getStockCode();

    public void handle(String code, String body) {
        StockDataConsumer consumer = stockDataConsumerManager.getConsumer(code);
        if (null != consumer) {
            consumer.handle_data(body);
        }
    }

}
